//
//  UITabBarController+tool.m
//  ios开发常用工具类收集
//
//  Created by zxy on 2018/4/17.
//  Copyright © 2018年 zssh. All rights reserved.
//

#import "UITabBarController+tool.h"

@implementation UITabBarController (tool)

-(void)addChildCtl:(UIViewController *)childCtl title:(NSString *)title normalImageName:(NSString *)normalImageName selectedImageName:(NSString *)selectedImageName{
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:childCtl];
    nav.navigationBarHidden=YES;
    if(normalImageName.length || selectedImageName.length){
        childCtl.tabBarItem=[[UITabBarItem alloc]initWithTitle:title image:[[UIImage imageNamed:normalImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    }
    //    [childCtl.tabBarItem setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14],NSForegroundColorAttributeName: [UIColor ]} forState:UIControlStateNormal];
    //    [childCtl.tabBarItem setTitleTextAttributes:@{} forState:UIControlStateSelected];
    [self addChildViewController:nav];
}


-(void)addChildCtl:(UIViewController *)childCtl title:(NSString *)title normalTitleColor:(UIColor *)normalTitleColor selectedTitleColor:(UIColor *)selectedTitleColor titleFontSize:(CGFloat)titleFont normalImageName:(NSString *)normalImageName selectedImageName:(NSString *)selectedImageName{
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:childCtl];
    nav.navigationBarHidden=YES;
    if(normalImageName.length || selectedImageName.length){
        childCtl.tabBarItem=[[UITabBarItem alloc]initWithTitle:title image:[[UIImage imageNamed:normalImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    }
    [childCtl.tabBarItem setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:titleFont],NSForegroundColorAttributeName: normalTitleColor} forState:UIControlStateNormal];
    [childCtl.tabBarItem setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:titleFont],NSForegroundColorAttributeName: selectedTitleColor} forState:UIControlStateSelected];
    [self addChildViewController:nav];
}

@end
